package cn.configleon.password.encrypt;

import org.jasypt.util.text.BasicTextEncryptor;

public class Encryptor {
    
    private static String SALT = "One more into the fray..." + "Into the last good fight I'll ever know."
            + "Live and die on this day..." + "Live and die on this day...";
            
    private static BasicTextEncryptor bte = new BasicTextEncryptor();

    static {
        bte.setPassword(SALT);
    }

    public static String encrypt(String str) {
        return bte.encrypt(str);
    }

    public static String decrypt(String str) {
        return bte.decrypt(str);
    }

    public static String encrypt(String str, String salt) {
        BasicTextEncryptor bte = new BasicTextEncryptor();
        bte.setPassword(salt);
        return bte.encrypt(str);
    }

    public static String decrypt(String str, String salt) {
        BasicTextEncryptor bte = new BasicTextEncryptor();
        bte.setPassword(salt);
        return bte.decrypt(str);
    }
    
}
